package com.hoas.api.core.extend;

import java.io.IOException;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import  com.hoas.api.core.intf.ParamConverter;

public class DefaultParamConverter implements ParamConverter {

	private static final Logger logger = LoggerFactory.getLogger(DefaultParamConverter.class);
	
	private static ObjectMapper objectMapper = new ObjectMapper();
	
	@SuppressWarnings("unchecked")
	@Override
	public Map<String, Object> convert(String paramStr) {
		try {
			return objectMapper.readValue(paramStr, Map.class);
		} catch (JsonParseException e) {
			logger.error(e.getMessage(), e);
		} catch (JsonMappingException e) {
			logger.error(e.getMessage(), e);
		} catch (IOException e) {
			logger.error(e.getMessage(), e);
		}
		return null;
	}
	
	

}
